﻿using B.S.Data.MES.API.Applications.QualityManagement.ExamineDesignCommand.Commands;
using B.S.Domain.BasicData.QualityManagement;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.QualityManagement.ExamineDesignCommand.CommandHandlers
{
    public class DeleteExamineDesignCommandHandler : IRequestHandler<DeleteExamineDesignCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<ExamineDesign> _examinedesignRepository;
        public DeleteExamineDesignCommandHandler(IBaseRepository<ExamineDesign> examinedesignRepository)
        {
            _examinedesignRepository = examinedesignRepository;
        }
        public Task<APIRequst<int>> Handle(DeleteExamineDesignCommand request, CancellationToken cancellationToken)
        {
            var ment = _examinedesignRepository.GetAll().FirstOrDefault(x=>x.DesignId==request.designId);
            ment.isDel = true;
            _examinedesignRepository.Update(ment);

            return Task.FromResult(new APIRequst<int>
            {
                Code = RequstCode.成功,
                Msg=RequstCode.成功.ToString()
            });
            
            
        }
    }
}
